<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>测试工具系统</title>
  
  <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="../static/css/bootstrap.css">
    <script src="../static/js/jQuery-1.12.4.min.js"></script>
    <script src="../static/js/bootstrap.js"></script>
    <script src="../static/js/scripts.js"></script>
</head>

<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <!-- <a class="navbar-brand" href="#">工具系统v0.0</a> -->
      <div>
        <p class="navbar-text">工具系统v0.0</p>
      </div>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <!--<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>-->
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">自动化 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <ul class="nav nav-tabs">
                <li><a href="#tab_pro_test"  data-toggle="tab">二代机自动化测试</a></li>
                <li><a href="#tab_pro_test"  data-toggle="tab">T-BOX自动化测试</a></li>
            </ul>
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">协议 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <ul class="nav nav-tabs">
                <li><a href="#tab_pro_test"  data-toggle="tab">808协议</a></li>
                <li><a href="#tab_pro_test_hangbiao"  data-toggle="tab">杭标协议</a></li>
                <li><a href="#tab_pro_test_17691"  data-toggle="tab">17691协议</a></li>
            </ul>
          </ul>
        </li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">其他<span class="caret"></span></a>
          <ul class="dropdown-menu">
            <ul class="nav nav-tabs">
                <li><a href="#tab_pro_test"  data-toggle="tab">常用工具</a></li>
                <li><a href="#tab_pro_test"  data-toggle="tab">想不到</a></li>
                <li><a href="#tab_pro_test"  data-toggle="tab">想不到</a></li>
            </ul>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

<div id="TabContent" class="tab-content">
<div class="tab-pane fade" id="tab_pro_test">
    <form role="form">
        <div class="form-group">
            <label for="name">输入报文</label>
            <textarea class="form-control" rows="5" id="pro_data"></textarea> <!--pro_data=用户输入报文-->
        </div>
        <a type="button" class="btn btn-danger" onclick="pro_test()">分析</a>
        <button type="button" class="btn btn-default" onclick="clear_input()">清除</button>
    </form>
    <div class="jumbotron" style="margin-top:1px;"><pre id="analyse_result"></pre></div>
    </div>
<div class="tab-pane fade" id="tab_pro_test_hangbiao">
    <form role="form">
        <div class="form-group">
            <label for="name">输入报文</label>
            <textarea class="form-control" rows="5" id="pro_data_hangbiao"></textarea> <!--pro_data=用户输入报文-->
        </div>
        <a type="button" class="btn btn-danger" onclick="pro_test_hangbiao()">分析</a>
        <button type="button" class="btn btn-default" onclick="clear_input_hangbiao()">清除</button>
    </form>
    <div class="jumbotron" style="margin-top:1px;"><pre id="analyse_result_hangbiao"></pre></div>
    </div>
<div class="tab-pane fade" id="tab_pro_test_17691">
    <form role="form">
        <div class="form-group">
            <label for="name">输入报文</label>
            <textarea class="form-control" rows="5" id="pro_data_17691"></textarea> <!--pro_data=用户输入报文-->
        </div>
        <a type="button" class="btn btn-danger" onclick="pro_test_17691()">分析</a>
        <button type="button" class="btn btn-default" onclick="clear_input_17691()">清除</button>
    </form>
    <div class="jumbotron" style="margin-top:1px;"><pre id="analyse_result_17691"></pre></div>
	</div>
</div>
</body>
<script type="text/javascript">
    //创建一个StringBuffer类 ，此类有两个方法：一个是append方法一个是toString方法
    function StringBuffer() {
        this.__strings__ = [];
    };
    StringBuffer.prototype.append = function(str) {
        this.__strings__.push(str);
    };
    StringBuffer.prototype.toString = function() {
        return this.__strings__.join('');
    };
        $('#analyse_data').click(function () {
            var cbuffer = new StringBuffer();//声明一个对象
            var contents= new Array();
            var prodatastr="";
            contents = $("#pro_data").val().split("\n");
            console.log(typeof(contents));
            for (i=0;i<contents.length ;i++ ) 
            { 
                console.log(i,contents[i]); //分割后的字符输出 
                var strStartIndex = contents[i].indexOf(":");
                var strEndIndex = contents[i].indexOf("|");
                if(strStartIndex < 0 && strEndIndex < 0){
                    console.log("没有：也没有|");
                    cbuffer.append(contents[i].substring(0, contents[i].length));
                }else if(strStartIndex < 0 && strEndIndex > 0){
                    console.log("没有：");
                    cbuffer.append(contents[i].substring(0, strEndIndex));
                }else if(strEndIndex < 0 && strStartIndex > 0){
                    console.log("没有|");
                    cbuffer.append(contents[i].substring(strStartIndex+2, contents[i].length));
                }else{
                    console.log("正常");
                    cbuffer.append(contents[i].substring(strStartIndex+2, strEndIndex));
                }
            }
            prodatastr = cbuffer.toString();
            console.log(prodatastr);
            var dest = "";
            if (prodatastr.length != 0){
                dest=prodatastr.replace(/(^[\s\n\t]+|[\s\n\t]+$)/g, "");
                dest=dest.replace(/\s+/g, "");
                dest = dest.replace("7d02", "7e");
                dest = dest.replace("7d01", "7d");
                prodatastr = dest;
                console.log(prodatastr);
            }
        });
        //$('#claer_data').click(function () {
        //    console.log("clear test");
        //    $("#pro_data").text()="";
        //});
</script>
</html>

